package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.MallActivityOrder;
import com.ktgj.customer.service.IMallActivityOrderService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 活动订单,暂时团单使用Controller
 * 
 * @author ruoyi
 * @date 2022-05-30
 */
@RestController
@RequestMapping("/mallActivityOrder")
public class MallActivityOrderController extends BaseController
{
    @Autowired
    private IMallActivityOrderService mallActivityOrderService;

    /**
     * 查询活动订单,暂时团单使用列表
     */
    @PreAuthorize(hasPermi = "customer:order:list")
    @GetMapping("/list")
    public TableDataInfo list(MallActivityOrder mallActivityOrder)
    {
        startPage();
        List<MallActivityOrder> list = mallActivityOrderService.selectMallActivityOrderList(mallActivityOrder);
        return getDataTable(list);
    }

    /**
     * 导出活动订单,暂时团单使用列表
     */
    @PreAuthorize(hasPermi = "customer:order:export")
    @Log(title = "活动订单,暂时团单使用", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallActivityOrder mallActivityOrder) throws IOException
    {
        List<MallActivityOrder> list = mallActivityOrderService.selectMallActivityOrderList(mallActivityOrder);
        ExcelUtil<MallActivityOrder> util = new ExcelUtil<MallActivityOrder>(MallActivityOrder.class);
        util.exportExcel(response, list, "活动订单,暂时团单使用数据");
    }

    /**
     * 获取活动订单,暂时团单使用详细信息
     */
    @PreAuthorize(hasPermi = "customer:order:query")
    @GetMapping(value = "/{activityOrderId}")
    public AjaxResult getInfo(@PathVariable("activityOrderId") Long activityOrderId)
    {
        return AjaxResult.success(mallActivityOrderService.selectMallActivityOrderById(activityOrderId));
    }

    /**
     * 新增活动订单,暂时团单使用
     */
    @PreAuthorize(hasPermi = "customer:order:add")
    @Log(title = "活动订单,暂时团单使用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallActivityOrder mallActivityOrder)
    {
        return toAjax(mallActivityOrderService.insertMallActivityOrder(mallActivityOrder));
    }

    /**
     * 修改活动订单,暂时团单使用
     */
    @PreAuthorize(hasPermi = "customer:order:edit")
    @Log(title = "活动订单,暂时团单使用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallActivityOrder mallActivityOrder)
    {
        return toAjax(mallActivityOrderService.updateMallActivityOrder(mallActivityOrder));
    }

    /**
     * 删除活动订单,暂时团单使用
     */
    @PreAuthorize(hasPermi = "customer:order:remove")
    @Log(title = "活动订单,暂时团单使用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{activityOrderIds}")
    public AjaxResult remove(@PathVariable Long[] activityOrderIds)
    {
        return toAjax(mallActivityOrderService.deleteMallActivityOrderByIds(activityOrderIds));
    }
}
